<template>
  <view id="editPass">
      <view class="list list1">
          <view class="left">原密码</view>
          <view class="right">
              <input type="text" v-model="oldPass" placeholder="请输入">
          </view>
      </view>
      <view class="list">
          <view class="left">新密码</view>
          <view class="right">
              <input type="text" v-model="newPass" placeholder="请输入">
          </view>
      </view>
      <view class="list">
          <view class="left">确认密码</view>
          <view class="right">
              <input type="text" v-model="newPass2" placeholder="请输入">
          </view>
      </view>

      <view class="btn" @click="submit">提交</view>
  </view>
</template>

<script>
import md5 from "js-md5";
export default {
    data(){
        return{
            oldPass:"",
            newPass:"",
            newPass2:""
        }
    },
    methods:{
        submit(){
            if(this.newPass!=this.newPass2){
                uni.showToast({
					icon:"none",
					title:'两次密码不一致'
                })
                return false
            }
            this.$store.dispatch("editPassword",{old_pass:md5(this.oldPass),new_pass:md5(this.newPass)}).then(res=>{
                if(res.code==1){
                    uni.redirectTo({
                        url:"/pages/login/index"
                    })
                }
                
            })
        }
    }
}
</script>

<style lang="scss" scoped>
#editPass{
    .list{
        display: flex;
        justify-content: space-between;
        background: #fff;
        
        height: 80rpx;
        align-items: center;
        font-size: 28rpx;
        box-sizing: border-box;
        padding: 0 20rpx;
        &.list1{
            margin: 0rpx 0 40rpx 0;
        }
        .right{
            input{
                font-size: 28rpx;
                text-align: right;
            }
        }
    }
    .btn{
        background: #0077ff;
        color: #fff;
        text-align: center;
        width: 400rpx;
        line-height: 80rpx;
        border-radius: 40rpx;
        margin: 60rpx auto;
        font-size: 30rpx;
    }
}
</style>